﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace SnakeX
{
	/// <summary>
	/// This class represents an apple.
	/// </summary>
	public class SnakeXApple
	{

		/// <summary>
		/// Constructor.
		/// Initializing members.
		/// Setting first apple position.
		/// </summary>
		/// <param name="side">Apple side length</param>
		/// <param name="screenWidth">Screen width</param>
		/// <param name="screenHeight">Screen height</param>
		public SnakeXApple(int side, int screenWidth, int screenHeight)
		{
			this.side = side;
			this.screenWidth = screenWidth;
			this.screenHeight = screenHeight;

			random = new Random();
			RandomizeNewPosition();
		}


		/// <summary>
		/// Setting new randomized position for the apple.
		/// </summary>
		public void RandomizeNewPosition()
		{
			position = new Point(
				((random.Next(screenWidth - side)) / side) * side,
				((random.Next(screenHeight - side)) / side) * side);
		}



		/// <summary>
		/// Apple position.
		/// </summary>
		private Point position;

		public Point Position
		{
			get { return position; }
			set { position = value; }
		}



		/// <summary>
		/// Apple side length.
		/// </summary>
		private int side;

		public int Side
		{
			get { return side; }
			set { side = value; }
		}



		/// <summary>
		/// The random generator object.
		/// </summary>
		private Random random;

		/// <summary>
		/// Screen width.
		/// </summary>
		private int screenWidth;

		/// <summary>
		/// Screen height.
		/// </summary>
		private int screenHeight;
	}
}
